#include "Stack.h"

#include <iostream>
#include <string>

using namespace std;

Stack::Stack() {
    tail = -1;
}

void Stack::push(int x) {
    // tail++;
    if (tail == 19) {
        cout << "raise error \n";
        return;
    }
    datas[++tail] = x;
}

void Stack::pop() {
    if (tail == -1)
        cout << "stack is empty!\n";
    else
        tail--;
}

int Stack::top() const {
    return tail == -1 ? 0 : datas[tail];
}

bool Stack::empty() const {
    return tail == -1;
}

void Stack::clear() {
    tail = -1;
}